﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;

using System.Web.UI;
using System.Web.UI.WebControls;

namespace DAL
{
    public static class   Parametros
    {

        public static string LangES = "es-ES";  //para controlar el idioma 
        public static string LangUS = "en-US";  //para controlar el idioma 


       public static  String strConnString =
           ConfigurationManager.ConnectionStrings["dbGestionConnectionString"].ConnectionString;

       public static String dbGesPag =
         ConfigurationManager.ConnectionStrings["dbGesPagConnectionString"].ConnectionString;

       public static String dbConCar =
       ConfigurationManager.ConnectionStrings["dbConCarConnectionString"].ConnectionString;
       

       //public static String ubicacionServerLocal="\\\\192.168.1.203\\log v2.0\\EOMGestion2\\App_Data\\Presupuesto";
      

        public static int timeSleepTask = 5000;

        public static int MaxExcelRows = 10000;
      

        public static int GenerarID()
        {
            string str = Guid.NewGuid().ToString();
            Guid guid = new Guid(str);
            byte[] _bytes = guid.ToByteArray();
            int id = ((int)_bytes[0]) | ((int)_bytes[1] << 8) | ((int)_bytes[2] << 16) | ((int)_bytes[3] << 24);
            return id;
        }

        public static byte[] GetLogoEmpresa(int idEmpresa)
        {
            //debe de estar en la session


            string archivoLogo = DbUtil.Db.Empresas.Single(p => p.idInternal == idEmpresa).Logo;

            if (archivoLogo == null | archivoLogo.Trim() == String.Empty)
            {
                throw new Exception("No existe Logo de la Empresa");
            }

            string rutaLogo = System.Web.HttpContext.Current.Server.MapPath("~/App_Data/Empresa/Logo/" + archivoLogo);

            return  UtilityExtensions.Util.FileToBytesImage(rutaLogo);


        }

        public static int GetEmpleadoLogin()
        {
            try
            {
                int idEmpleadoEmisor =
                    int.Parse(System.Web.HttpContext.Current.Session["idEmpleado"].ToString());
                return idEmpleadoEmisor;
               
            }
            catch (Exception )
            { // enrutamos para  el login
                //System.Web.HttpContext.Current.Response.Write("Seccion terminada");
               // System.Web.HttpContext.Current.Response.Redirect("../LoginForm.aspx");
                
                throw new Exception("Session cerrada , Ingrese Al Sistema");
            }
        }

        
    }
}
